/*
 * Gyroscope.h
 *
 *  Created on: Jan 19, 2014
 *      Author: ppks
 */

#ifndef GYROSCOPE_H_
#define GYROSCOPE_H_

#include "config.h"

/******************************************************************************/
/* Gyroscope Configuration                                                    */
/******************************************************************************/
#define GYRO_GLITCH_RANGE           800

#if (GYROSCOPE_TYPE == MPU6050)
/* Define the I2C address if not defined yet in global config.h */
#ifndef GYRO_ADDRESS
    #define GYRO_ADDRESS            0x68   /* address pin AD0 low (GND), default for FreeIMU v0.4 and InvenSense evaluation board */
#endif /* #ifndef GYRO_ADDRESS */

/* Define the data register */
#define GYRO_DATA_REGISTER          0x43

#define GYRO_SCALE                  (4 / 16.4 * PI / 180.0 / 1000000.0)   /* MPU6050 and MPU3050   16.4 LSB = 1 deg/s */

/* Define built-in Low-Pass Filter configuration */
#if defined(MPU6050_LPF_256HZ) || defined(MPU6050_LPF_188HZ) || defined(MPU6050_LPF_98HZ) || defined(MPU6050_LPF_42HZ) || defined(MPU6050_LPF_20HZ) || defined(MPU6050_LPF_10HZ) || defined(MPU6050_LPF_5HZ)
    #if defined(MPU6050_LPF_256HZ)
        #define MPU6050_DLPF_CFG    0
    #endif
    #if defined(MPU6050_LPF_188HZ)
        #define MPU6050_DLPF_CFG    1
    #endif
    #if defined(MPU6050_LPF_98HZ)
        #define MPU6050_DLPF_CFG    2
    #endif
    #if defined(MPU6050_LPF_42HZ)
        #define MPU6050_DLPF_CFG    3
    #endif
    #if defined(MPU6050_LPF_20HZ)
        #define MPU6050_DLPF_CFG    4
    #endif
    #if defined(MPU6050_LPF_10HZ)
        #define MPU6050_DLPF_CFG    5
    #endif
    #if defined(MPU6050_LPF_5HZ)
        #define MPU6050_DLPF_CFG    6
    #endif
#else
    /* Default settings LPF 256Hz/8000Hz sample */
    #define MPU6050_DLPF_CFG        0
#endif
#endif /* (GYROSCOPE_TYPE == MPU6050) */

/********************************************************************************/
/* Exported Variables Declaration                                               */
/********************************************************************************/

/********************************************************************************/
/* Exported Functions Prototypes                                                */
/********************************************************************************/
extern void Gyroscope_Init(void);
extern void Gyroscope_ReadRawADC(void);

#endif /* GYROSCOPE_H_ */
